home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / wlib11_2.zip / EXAMPLES.EXE / EXAM90.C < prev    next >
C/C++ Source or Header  |  1991-03-13  |  3KB  |  66 lines

  1.   #include "menu.h"
  2.   int menu_func();
  3.  
  4.   POPUP_MENU_ENTRY menu_items[] = {
  5.                                   " Load      F3", /* entry name */
  6.                                     1,             /* row number */
  7.                                    'L',            /* hotkey */
  8.                                     F3,            /* secondary hotkey */
  9.                                     menu_func,     /* function to call
  10.                                                       if chosen */
  11.  
  12.                                  /* now do rest of the popup entries */
  13.                                   " Pick  Alt-F3",2, 'P',ALTF3,menu_func,
  14.                                   " New"         ,3, 'N',0,menu_func,
  15.                                   " Save      F2",4, 'S',F2,menu_func,
  16.                                   " Write to    ",5, 'W',0,menu_func,
  17.                                   " Directory   ",6, 'D',0,menu_func,
  18.                                   " Change Dir"  ,7, 'C',0,menu_func,
  19.                                   " OS shell"    ,8, 'O',0,menu_func,
  20.                                   " Quit  Alt-X"  ,9,'Q',ALTX,menu_func,
  21.  
  22.                                  /* Terminate with a CWL_NULL and 0 */
  23.  
  24.                                   CWL_NULL,0};
  25.   unsigned int menu_colors[5];
  26.   POPUP_MENU_PTR p;
  27.  
  28.   main()
  29.   {
  30.     WindowInitializeSystem();
  31.     WindowSaveInitial(0);  /* Remember to save the initial screen */
  32.    /* define colors */
  33.     menu_colors[ENTRYCOLOR] = CREATE_VIDEO_ATTRIBUTE(white,black);
  34.     menu_colors[BORDERCOLOR] = CREATE_VIDEO_ATTRIBUTE(white,black);
  35.     menu_colors[HOTKEYCOLOR] = CREATE_VIDEO_ATTRIBUTE(white,blue);
  36.     menu_colors[HIGHLIGHTCOLOR] = CREATE_VIDEO_ATTRIBUTE(cyan,black);
  37.     menu_colors[UNAVAILCOLOR] = CREATE_VIDEO_ATTRIBUTE(white,black);
  38.  
  39.    /* create a POPUP_MENU_PTR */
  40.    p = PopupCreateMenu(menu_items,menu_colors, 1,1,6,WNULLFN,VWNULLFN);
  41.    PopupSetOptions(p,POPUPSTATIC,1);
  42.    PopupSelectMenu(p,  /* POPUP_MENU_PTR */
  43.                      1,  /* rank of popup window */
  44.                      1   /* menu entry to start on */
  45.                     );
  46.   }
  47.  
  48.  
  49.   int menu_func(POPUP_MENU_PTR p, int which)
  50.   {
  51.     WPOINTER w;
  52.     w = WindowInitialize(BORDER,15,15,40,4,CREATE_VIDEO_ATTRIBUTE(black,white),
  53.                CREATE_VIDEO_ATTRIBUTE(black,white), SINGLEBOX);
  54.     WindowOpen(w);
  55.     WindowClear(w);
  56.     WindowPrintf(w,"You have selected %s",menu_items[which-1].entry_name);
  57.     WindowWriteCenterString(w,"Press a key to continue",3);
  58.     WindowDisplay(w,1,NOEFFECT);
  59.     GET_KEY();
  60.     WindowFree(w,NOEFFECT);
  61.     if (which == 9)
  62.       return POPUP_EXIT;
  63.     else
  64.     return POPUP_CONTINUE;
  65.   }
  66.